package com.nhjf.dao.total;

import org.apache.commons.lang.StringUtils;
import org.hibernate.Criteria;
import org.hibernate.FetchMode;
import org.hibernate.criterion.MatchMode;
import org.hibernate.criterion.Restrictions;
import org.springframework.stereotype.Repository;

import com.nhjf.dao.BaseDao;
import com.nhjf.model.total.CourseCount;
import com.nhjf.pojo.qo.total.CourseCountQo;

@Repository
public class CourseCountDao extends BaseDao<CourseCount, CourseCountQo>{

	@Override
	protected Criteria buildCriteria(Criteria criteria, CourseCountQo qo) {
		// TODO Auto-generated method stub
        if(qo!=null){
            if(!StringUtils.isEmpty(qo.getName())) {
              	 criteria.add(Restrictions.like("name", qo.getName(),MatchMode.ANYWHERE));
              }
            if(!StringUtils.isEmpty(qo.getTeacherName())) {
             	 criteria.add(Restrictions.like("teacherName", qo.getTeacherName(),MatchMode.ANYWHERE));
             }
            if(!StringUtils.isEmpty(qo.getOrganizationName())) {
             	 criteria.add(Restrictions.like("organizationName", qo.getOrganizationName(),MatchMode.ANYWHERE));
             }

        }

        return criteria;
	}

	@Override
	protected Class<CourseCount> getEntityClass() {
		// TODO Auto-generated method stub
		return CourseCount.class;
	}

}
